Propogate USB error in libusb (Linux, Mac) up the stack so realtime
authorrobertl <robertl>
Sun, 15 Oct 2006 22:51:51 +0000 (22:51 +0000)
committerrobertl <robertl>
Sun, 15 Oct 2006 22:51:51 +0000 (22:51 +0000)
positioning code can error out gracefully.

Fix minor mem leak in Garmin USB position read case.

garmin.c
jeeps/gpsusbread.c

index d51bb5a485a5cc9a1335abd1066083568e35d743..3f74b8088210e1e96fdec5fc56a0bbdf3d304aac 100644 (file)
--- a/garmin.c
+++ b/garmin.c
@@ -481,6 +481,12 @@ pvt_read(void)
                return wpt;
        } 
 
+       if (gps_errno) {
+               fatal(MYNAME ": Fatal error reading position.\n");
+       }
+
+       GPS_Pvt_Del(&pvt);
+
        return NULL;
 }
 
index 1cdce1df2051c32e1fb783bcb8c769761be04ec7..e266011ddaed5c946e815c94b9f20d5396b161bb 100644 (file)
@@ -40,7 +40,12 @@ do_over:
        n = gusb_cmd_get(&pkt, sizeof(pkt));
 
        if ( n < 0 ) {
-fprintf(stderr, "Eeek %d\n", n);
+               /*
+                * We (probably) used to have a GPS and it went away 
+                * while we were speaking with it.  Perhaps batteries 
+                * died or it was unplugged or something.
+                */
+               gps_errno = PROTOCOL_ERROR;
                return n;
        }